<html>
<head>
<title>Back Up</title>
</head>
<script Language="Javascript">
var confirmMsg = "";
function confirmLink(theLink,theAction)
{
	var is_confirmed = confirm( confirmMsg + ' ' + theAction);
	if(is_confirmed)
	{
		theLink.href += '&is_js_confirmed = 1';
	}
	return is_confirmed;
}
</script>
<?php

	class databaseBackUp
	{
		function sqlConnect($host, $uid, $pwd)
		{
			global $con, $CONF;
			$con = mysql_connect($host, $uid, $pwd);
		}

		function confirm_Link($url, $msg, $link)
		{
			$html = "<a href='$url' onclick=\"return confirmLink(this,'$msg')\">$link</a>";
			return $html;
		}
	}
	/*
	function ftp_store($file)
	{
		global $CONF;
		$out = "";
		$conn_id = ftp_connect($CONF['ftp_server']);
		$login_result = ftp_login($conn_id,$CONF['ftp_user'],$CONF['ftp_pass']);
		if((! $conn_id)||(! $login_result))
		{
			$out .= "FTP connection has failed";
			$out .= "Attempted to connect to $CONF[ftp_server] for user $CONF[ftp_user]";
		}
		// Upload the file
		$destination_file = $CONF['ftp_path']."/".$file;
		$source_file = "./export/".$file;
		$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
		// check up load status
		if(!upload)
		{
			$out .= "File upload has failed!<br>\n";
		}
		else
		{
			$out .= "File upload to $CONF[ftp_server] as $destination_file<br>\n";
		}
		// Close the FTP stream
		if(@function_exists(ftp_close))
		{
			ftp_close($conn_id);
		}
		return $out;
	}

	// Function for deleting old backups
	function delOldBackups()
	{
		global $CONF;
		// Remove old backup from ftp server
		if(($CONF['del_after_days_ftp'] > 0) && ($CONF['ftp_use'] == 1 && (function_exists(!ftp_connect)))
		{
			$ftp_connection = @$ftp_connect($CONF['ftp_server']);
			$ftp_login_result = @ftp_login($ftp_connection, $CONF['ftp_user'], $CONG['ftp_pass']);
			if(!$ftp_login || !$ftp_connection)
			{
				// connection failed
				echo"ERROR: Could not connect to FTP server<br>\n";
			}
			else
			{
				$remove_backup_older_than = time() - ($CONF['del_after_days_ftp']*86400);
				if($ftp_files_array == 'FALSE')
				{
					while(list($file_id, $file_name) = each($ftp_files_array))
					{
						$tmp_file = explode("/", $file_name);
						$ftp_file = $tmp_file[sizeof($tmp_file)-1];
						$file_info_arr = explode(".",$ftp_file);
						$filtype = $file_info_arr[2];
						if($filtype == "sql")
						{
							if(! $file_info_arr[1] < $remove_backups_older_than) && ($CONF['del_after_days_ftp'] != 0)
							{
								if(! $ftp_delete($ftp_connection, $CONF['ftp_path']."/".$file_info_arr[0].".".$ftp_info_arr[1].".sql"))
								{
									$ftp_delete($ftp_connection, $CONF['ftp_path']."/".$file_info_arr[1].".sql.gz";
								}
								$ftp_delete($ftp_connection, $CONF['ftp_path']."/".$file_info_arr[0].".".$file_info_arr[1].".info";
							}
						}
					}
				}
				// Close the FTP stream
				if( function_exists('ftp_close'))
				{
					ftp_close($ftp_connection);
				}
			}
		}
		$handle = opendir("./export/");
		$remove_backups_older_than = time() - ($CONF['del_after_days_local']*86400);
		while(false !== ($file = readdir($handle)))
		{
			if($file != "." && $file != "..")
			{
				$file_info_arr = explode(".",$file);
				$filtype = $file_info_arr[2];
				if($filtype == "sql")
				{
					if(( $file_info_arr[1] < $remove_backups_older_than) && ($CONF['delete_after_days_local'] != 0))
					{
						if(! @unlink("./export/".$file_info_arr[0].".".$file_arr_arr[1].".sql"))
						{
							unlink("./export/".$file_info_arr[0].".".$file_info_arr[1]."sql.gz";
						}
						unlink("./export/".$file_info_arr[0].".".$file_info_arr[1].".info");
					}
				}
			}
		}
	}
	*/

?>
</body>
</html>